﻿using System.Configuration;
using System.Diagnostics;
using System.Diagnostics.Contracts;

namespace OTE.Infrastructure.ConfirgurationEngine
{
    public class Configurator : IConfigurator
    {
        public string GetAppSettingString(string key)
        {
            return ConfigurationManager.AppSettings[key];
        }

        public string GetConnectionString(string key)
        {
            return ConfigurationManager.ConnectionStrings[key].ConnectionString;
        }

        [DebuggerStepThrough]
        public T GetSection<T>(string sectionName)
        {
            Contract.Assert(!string.IsNullOrEmpty(sectionName), "SectionName [" + sectionName + "] is null or empty");

            return (T)ConfigurationManager.GetSection(sectionName);
        }
    }
}